A comparator is an electronic component or device that compares two inputs (such as input voltages and/or currents). The output of the comparator indicates which input has the larger value. For example, where the inputs are two input voltages, the output indicates which input voltage is the higher voltage. The output of the comparator is typically a digital voltage, in that it takes one of two levels, such as logic 0 and logic 1.
FIG. 1 shows an example of a comparator 100. The comparator 100 includes positive and negative voltage inputs 102 and 104, to which input voltages v1 and v2 are provided. The comparator output 106 carries a voltage vout that indicates which of the voltages v1 and v2 is higher. Typically, the output voltage vout is logic 1 when v1 is greater than v2, and logic when v2 is greater than v1.
If the inputs are very close to each other in value then the output can switch between levels very quickly. Furthermore, a change in the output of the comparator may cause a change in conditions in which the comparator is used, causing the output to quickly change back again.
Hysteresis may be introduced into the comparator to reduce the possibility of the comparator output switching levels quickly. FIG. 2 shows an example of the output vout 200 of a comparator with hysteresis. A comparator with no hysteresis may switch output levels when a difference vdiff between the inputs is a (a may be zero volts). A comparator with hysteresis switches from logic 0 to logic 1 when vdiff rises to b, and from logic 1 to logic 0 when vdiff falls c, where b>c. Thus, if Vdiff reaches b, then the output of the comparator changes from logic 0 to logic 1, whereas vdiff must fall to c before the comparator changes from logic 1 to logic 0.
An example of a comparator 300 that includes hysteresis is shown in FIG. 3. The comparator 300 includes a current stage 302 to which input voltages v1 and v2 are provided. The current stage 302 has an output current ic that is proportional to the difference vdiff between the input voltages, vdiff=v1−v2. the output current ic is provided to the input of an amplifer 304 that amplifies the current input and provides an output voltage vout that indicates whether the input current is positive or negative.
The comparator 300 includes a first current source 310 and a first switch 312 connected in series between a positive power supply voltage Vdd and the input to the amplifier 304. The comparator 300 also includes a second current source 314 and a second switch 316 connected in series between the input to the amplifier 304 and ground (or alternatively a negative power supply voltage Vss).
The switches 312 and 316 are controlled such that when the output vout of the amplifier 304 is logic 1, the switch 312 is closed and the switch 316 is open. Thus, a current I1 is sourced to the input of the amplifier 304, and is added to the current ic from the current stage 302. As a result, the current ic must drop further to switch the output of the amplifier from 1 to 0 compared to if the current I1 is not present. Similarly, when the output vout of the amplifier 304 is logic 0, the switch 312 is open and the switch 316 is closed. Thus, a current 12 is sunk from the input of the amplifier 304, and is subtracted from the current ic from the current stage 302. As a result, the current ic must rise further to switch the output of the amplifier from 0 to 1 compared to if the current I2 is not present. Thus, the comparator 300 has hysteresis such as that shown in FIG. 2.
The current stage 302 includes transistors that have a bias current. Changes in operating conditions of the comparator 300, such as changes in temperature and/or power supply voltages, may cause the bias current to change, causing the transconductance of the current stage 302 to change. Thus, the positions of b and c in FIG. 2 may change.
It is an object of embodiments of the invention to at least mitigate one or more of the problems of the prior art.